package com.jhc.yolo_web.controller;

import ai.onnxruntime.OrtException;
import com.jhc.yolo_web.service.YoloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class YoloController {

    @Autowired
    YoloService service;

    @PostMapping("/detection")
    public String detection(MultipartFile file) throws IOException, OrtException {
        //[{"label":"dog","bbox":[39.546623,22.788477,146.47032,182.329],"confidence":0.5121489},{"label":"dog","bbox":[225.81134,64.90155,334.0,184.04126],"confidence":0.50148803},{"label":"dog","bbox":[130.21144,50.03253,263.78952,186.3689],"confidence":0.4584485}]
        return service.detection(file);
    }
}
